package fr.afcepf.atod18.restaurants.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import fr.afcepf.atod18.restaurants.entity.Promotion;
import fr.afcepf.atod18.utilitaires.dao.IGenericDao;

@Service
@Transactional
public class ServicePromotion implements IServicePromotion {
	@Autowired
	IGenericDao<Promotion> daoPromotion;


	@Override
	public void ajouter(Promotion promotion) {
		daoPromotion.save(promotion);
	}
	@Override
	public Promotion mettreAJour(Promotion promotion) {
	    return daoPromotion.update(promotion);
	}
	@Override
	public Promotion rechercherParId(int id) {
	    return daoPromotion.findOne(id);
	}
	@Override
	public List<Promotion> rechercherTout() {
		return daoPromotion.findAll();
	}
	@Override
	public void supprimerParId(int id) {
	    daoPromotion.deleteById(id);
	}
	@Override
	public void supprimer(Promotion promotion) {
	    daoPromotion.delete(promotion);
	}
    @Override
	public void supprimerListe(List<Promotion> liste) {
		daoPromotion.deleteList(liste);
	}
    @Override
    public List<Promotion> rechercherParNom(String nomColonne, String libelle) {
        return daoPromotion.findByName(nomColonne, libelle);
    }


    public IGenericDao<Promotion> getDaoPromotion() {
		return daoPromotion;
	}
	public void setDaoPromotion(IGenericDao<Promotion> daoPromotion) {
		this.daoPromotion = daoPromotion;
	}
}
